home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 22 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: malloc woes with watcom C
  5. Date: Sun, 31 Dec 1995 23:07:30 GMT
  6. Organization: Netcom
  7. Message-ID: <30e71604.75895232@nntp.ix.netcom.com>
  8. References: <Pine.LNX.3.90.951230212738.7388A-100000-100000-100000@public.compusult.nf.ca>
  9. NNTP-Posting-Host: ix-dc12-14.ix.netcom.com
  10. X-NETCOM-Date: Sun Dec 31  3:06:44 PM PST 1995
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. Elliott Noel <jnoel@public.compusult.nf.ca> wrote:
  14.  
  15. |>
  16. |>  I looked through the faq and noticed a few answers pertaining to
  17. my 
  18. |>problem, but nothing that seems to help me.
  19. |>
  20. |>  My problem is that my program generates an exception and crashes
  21. during 
  22. |>legitimate calls to malloc().  It always seems to happen after a few
  23.  
  24. |>calls have already been made, and I can't localize the problem, just
  25. that 
  26. |>it occurs within the code for the malloc() function.
  27. |>
  28. |>  I am working under dos4gw flat memory model with Watcom C.  If
  29. anybody 
  30. |>has experienced this problem and knows anything about correcting it,
  31.  
  32. |>please contact me - you can imagine how cripling it is to my work
  33. not to 
  34. |>be able to allocate memory dynamically...
  35.  
  36. This almost always means you've stepped on some memory you shouldn't
  37. have.  Somewhere in your program you're overwritting some of the
  38. memory in the heap and malloc() is getting confused.
  39.  
  40. If so, there's nothing wrong with the malloc() that's failing.  The
  41. problem occurse earlier -- possibly much earlier.
  42.  
  43. Thee errors can be murder to find.  As a first step, try sprinkling
  44. your program with _heapchk() calls.  When _heapchk() returns something
  45. other than _HEAPOK, the heap is corrupt.
  46.  
  47. There are various heap checkers available, but I'm not sure if there
  48. are any for Watcom C.  These monitor heap activity and report errors
  49. when found.
  50.  
  51. Michael M Rubenstein
  52.